<!--
* description: 日期时间选择器（禁用当前日期之前的日期）
* author: lanrj
* createdDate: 2020-03-13
-->
<template>
  <el-col :span="span" id="crmafterDate">
    <lableName    :validrule="validrule"    :curLabelName="curLabelName" :isShowLabel="isShowLabel" :isRequire="isRequire"></lableName>
    <el-date-picker
      v-model="modelCode"
      type="datetime"
      placeholder="请选择日期"
      :picker-options="pickerOptions"
      :value-format="format"
      @change="sendCode"
      clearable
      :disabled="disabled"
      unlink-panels
    ></el-date-picker>
    <validateFormate :curLabelName="curLabelName" :validrule="validrule"></validateFormate>
  </el-col>
</template>

<script>
import { inputMixins } from "@/components/mixins/inputMixins";
export default {
  name: "crmafterDate",
  mixins: [inputMixins],
  components: {
    lableName: () => import("@/components/lableName"), //标题溢出样式组件
    validateFormate: () => import("@/components/validateFormate"), //校验提示样式组件
  },
  props: {
    dateType: { type: String, default: "daterange" },
    format: { type: String, default: "yyyy-MM-dd HH:mm:ss" },
    dateOptionsType: { type: String, default: "" },
    span: {
      type: Number,
      default: function() {
        return 6;
      }
    }
  },
  watch: {
    modelCode(val) {
      let str = this.codeField;
      debugger;
      if (str) {
        var arr = str.split(",");
        this.$parent.$parent.$parent.formField[arr[0]] = val[0];
        this.$parent.$parent.$parent.formField[arr[1]] = val[1];
      }
    }
  },
  watch: {
    modelCode(val) {
      let str = this.codeField;
      debugger;
      if (str) {
        var arr = str.split(",");
        this.$crmcf.__getParent(this, "formField", function(formField) {
          if (val != null) {
            formField[arr[0]] = val;
          } else {
            formField[arr[0]] = "";
          }
        });
      }
    }
  },
  // },
  data() {
    return {
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;
        }
      }
    };
  }
};
</script>
